<template>
    <div class="demo-collapse">
        <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="问题描述" name="des">
                <div class="detail">
                    <img class="image" src="../../../../../assets/swiper/背包问题.jpg">
                    <div class="detail-text">
                        <div class="text">
                            有N件物品和一个最多能背重量为w 的背包。第i件物品的重量是weight[i]，得到的价值是value[i]
                            。每件物品只能用一次，求解将哪些物品装入背包里物品价值总和最大。
                        </div>
                        <el-table :data="tableData" border style="width: 99%;">
                            <el-table-column prop="name" label="名称" />
                            <el-table-column prop="time" label="时间复杂度" />
                            <el-table-column prop="spatial" label="空间复杂度" />
                        </el-table>
                    </div>
                </div>
            </el-collapse-item>
            <el-collapse-item title="相关研究" name="3">
                <ul>
                    <li v-for="item in thesisData" :key="item.title">
                        <a :href="item.link" target="_blank">
                            <div class="thesis">
                                <img class="thesis-cover" src="../../../../../icons//thesis.svg" alt="">
                                <div class="thesis-title">
                                    {{ item.title }}
                                </div>
                                <div class="thesis-author">
                                    <span>作者：</span>{{ item.author }}
                                </div>
                                <div class="thesis-time">
                                    <span>时间：</span>{{ item.time }}
                                </div>
                                <div class="thesis-source">
                                    <span>来源：</span>{{ item.source }}
                                </div>
                            </div>
                        </a>
                    </li>
                </ul>
            </el-collapse-item>
            <el-collapse-item title="应用场景" name="4">
                <div class="detail">
                    <img class="use" src="../../../../../assets/01背包/01背包问题.jpg" alt="">
                    <div class="text">
                        背包问题(Knapsack problem)是组合优化和计算机理论科学的基本问题之一，在计算机理论和运筹学等领域中扮演着重要的角色。
                        自背包被提出之后，众多杰出科学家对背包问题进行了深入细致的研究和拓展，而关于背包问题理论的相关文章和文献也是不计其数，
                        可以说他是组合优化领域中重要的基石之一。同时，背包问题在现实中也有着广泛的应用，
                        很多实际问题都可以被抽象为背包问题，比如股市投资、国家预算、资源分配，工业生产和运输，军事等。
                    </div>
                </div>
            </el-collapse-item>
        </el-collapse>
    </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
const activeNames = ref(['1'])
const handleChange = (val: string[]) => {
    console.log(val)
}

// 相关研究部分
const thesisData = [
    {
        title: "基于集合求解01背包问题的跳跃点法",
        author: "王金燕",
        time: "2019年",
        source: "百度学术",
        link: "https://xueshu.baidu.com/usercenter/paper/show?paperid=167g0ab0xn4p0vr0pm1v0m209x191516&site=xueshu_se",
    },
    {
        title: "求解01背包问题的贪婪蛙跳算法",
        author: "高思齐，邢玉轩，肖侬，刘芳",
        time: "2018年",
        source: "百度学术",
        link: "https://xueshu.baidu.com/usercenter/paper/show?paperid=d8a0f8244801f2b6bb733203f75cfaac&site=xueshu_se",
    },
    {
        title: "利用动态规划解决01背包问题",
        author: "孙宇兴，谭芬",
        time: "2010年",
        source: "百度学术",
        link: "https://xueshu.baidu.com/usercenter/paper/show?paperid=b54e4fa726b5be77ff14ff7f018b9d7e&site=xueshu_se",
    },

]

// 复杂度表格描述
const tableData = [
    {
        name: '01背包',
        time: 'O(NW)',
        spatial: 'O(W)',
    },
]
</script>

<style scoped lang="scss">
* {
    list-style: none;
}

.image {
    width: 290px;
    border-radius: 10px;
    margin-right: 10px;
}

a {
    text-decoration: none;
    /* 去除默认的下划线 */
    outline: none;
    /* 去除旧版浏览器的点击后的外虚线框 */
    color: #000;
    /* 去除默认的颜色和点击后变化的颜色 */
}

.detail {
    display: flex;
    justify-content: center;
    align-items: end;

    .detail-box {
        display: flex;
        flex-direction: column;
    }

    .text {
        margin-left: 10px;
        margin-bottom: 10px;
        cursor: default;
    }

    .use {
        width: 240px;
        height: 150px;
        border-radius: 10px;
    }
}

// 相关研究部分
.thesis {
    width: 98%;
    position: relative;
    left: 20px;
    margin-bottom: 10px;
    font-weight: normal;
    background: #F5F5F5;
    border-radius: 10px;
    transition: all 0.2s linear;

    .thesis-title {
        position: absolute;
        top: 0;
        left: 5px;
    }

    .thesis-author {
        position: absolute;
        top: 25px;
        left: 120px;
    }

    .thesis-time {
        position: absolute;
        top: 45px;
        left: 120px;
    }

    .thesis-source {
        position: absolute;
        top: 65px;
        left: 120px;
    }

    &:hover {
        cursor: pointer;
        transform: translateX(-15px);
    }
}
</style>